<template>
  <el-card>
    <template>
      <el-table :data="good_tableDate" border stripe style="width: 100%">
        <el-table-column type="index"> </el-table-column>

        <el-table-column
          prop="shopPrice"
          label="当前可成交价"
        ></el-table-column>
        <el-table-column prop="bargainNum" label="该链接已砍次数">
        </el-table-column>

        <el-table-column prop="beginTime" label="链接生成时间">
          <template slot-scope="scope">
            {{ new Date(scope.row.beginTime).toLocaleString() }}
          </template>
        </el-table-column>
        <el-table-column prop="endTime" label="链接失效时间">
          <template slot-scope="scope">
            {{ new Date(scope.row.endTime).toLocaleString() }}
          </template>
        </el-table-column>
        <el-table-column prop="updateTime" label="最近一次砍价时间">
          <template slot-scope="scope">
            {{ new Date(scope.row.updateTime).toLocaleString() }}
          </template>
        </el-table-column>
        <el-table-column prop="goodset" label="操作">
          <template slot-scope="scope">
            <el-button
              @click="showEditMessage(scope.$index, scope.row)"
              type="success"
              plain
              >帮他来一刀吧</el-button
            >
            <el-button type="success" @click="showEditMessages(scope.row)" plain
              >查看该链接的砍价记录</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </template>
    <el-dialog
      title="砍价记录"
      :visible.sync="dialogVisible"
      width="70%"
      @close="this.dialogVisible = false"
      :close-on-click-modal="false"
    >
      <template>
        <el-table
          :data="barjl"
          border
          stripe
          style="width: 100%"
        >
          <el-table-column prop="helpUserName" label="帮助者姓名">
          </el-table-column>
          <el-table-column prop="beginTime" label="帮忙时间"> </el-table-column>
          <el-table-column prop="bargainMoney" label="帮了多少钱"> </el-table-column>
          
          <el-table-column prop="goodset" label="操作">
            <template slot-scope="scope">
              <el-button
                type="danger"
                icon="el-icon-delete"
                size="mini"
                @click="deleteGoods(scope.row)"
              ></el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </el-dialog>
  </el-card>
</template>




<script>
export default {
  created() {
    console.log('我的本地token', window.sessionStorage.getItem('token'))
    //文档就绪函数加载商品数据
    this.getGoodList()
    this.getGoodrecyclebin()
  },
  data() {
    return {
      dialogVisible: false,
      good_tableDate: [],
      barjl: [],
    }
  },
  methods: {
    //查看链接下的砍价记录
    showEditMessages(row) {
      this.axios
        .get(
          'https://localhost:44379/api/BargainPc/GetLinkDetails?id=' +
            row.launchBargainId
        )
        .then((res) => {
          //console.log(res.data.data,"看看看")
          //限时完成后的回调
          this.dialogVisible=true;
          this.barjl = res.data.data
        })
    },
    //待我砍价的列表
    getGoodList() {
      this.axios
        .get(
          'https://localhost:44379/api/BargainPc/GetHelpBargain?userId=' +
            window.sessionStorage.getItem('userId')
        )
        .then((res) => {
          //console.log(res.data.data,"看看看")
          //限时完成后的回调
          this.good_tableDate = res.data.data
        })
    },
    //点击帮忙砍价
    showEditMessage(index, row) {
      this.axios
        .get(
          'https://localhost:44379/api/BargainPc/BeginBargain?launchBargainId=' +
            row.launchBargainId +
            '&barId=' +
            row.bargainsBargainId +
            '&userId=' +
            window.sessionStorage.getItem('userId') +
            '&userName=' +
            window.sessionStorage.getItem('userName')
        )
        .then((res) => {
          //console.log(res.data.data,"看看看")
          //限时完成后的回调
          //提示
          //this.good_tableDate = res.data.data
          this.getGoodList()
          this.$message({
            message: res.data.msg,
            type: 'success',
          })
          //刷新页面
          //刷新页面
          //this.getGoodList()
        })
    },
  },
}
</script>
<style lang="less" scoped>
.good_table {
  .good_table_header {
    .good_search_input {
      width: 30%;
      float: left;
    }
    .good_search_button {
      background-color: #dcdfe6;
      box-shadow: 0 0 10px #ddd; //加阴影，向外扩散10像素
      float: left;
      width: 6%;
    }
    .good_add_button {
      width: 10%;
      padding-left: 20px;
      float: left;
    }
  }
}
</style>